package com.kamistoat.meimeimall.meimeimallmember.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.kamistoat.meimeimall.common.annotation.DubboAndHTTPExceptionCatch;
import com.kamistoat.meimeimall.common.annotation.LoginRequired;
import com.kamistoat.meimeimall.meimeimallmember.dao.MemberReceiveAddressDao;
import com.kamistoat.meimeimall.meimeimallmember.dubbo.MemberDubboInterfaceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.kamistoat.meimeimall.meimeimallmember.entity.MemberReceiveAddressEntity;
import com.kamistoat.meimeimall.meimeimallmember.service.MemberReceiveAddressService;
import com.kamistoat.meimeimall.common.utils.R;


/**
 * 会员收货地址
 *
 * @author kamistoat
 * @email linjianshanke@163.com
 * @date 2021-09-12 16:36:46
 */
@Api(tags="会员收货地址数据库操作")
@RestController
@RequestMapping("memberreceiveaddress")
public class MemberReceiveAddressController {
    protected Logger logger = LoggerFactory.getLogger(MemberReceiveAddressController.class);

    @Autowired
    MemberReceiveAddressService memberReceiveAddressService;
    @Autowired
    MemberReceiveAddressDao memberReceiveAddressDao;
    @Autowired
    MemberDubboInterfaceImpl memberDubboInterface;

    /**
     * 列表
     */
    @ApiOperation("从数据库获取列表")
    @GetMapping("/list")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    //@RequiresPermissions("meimeimallmember:memberreceiveaddress:list")
    public R list(@RequestParam Map<String, Object> params) {
        return R.ok();
    }


    /**
     * 信息
     */
    @ApiOperation("从数据库查询指定的POJO")
    @GetMapping("/member_receive_address_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    //@RequiresPermissions("meimeimallmember:memberreceiveaddress:info")
    public R info(@RequestParam("id") Long id) {
        MemberReceiveAddressEntity memberReceiveAddress = memberReceiveAddressService.getById(id);

        return R.ok().put("memberReceiveAddress", memberReceiveAddress);
    }

    /**
     * 保存
     */
    @ApiOperation("向数据库保存POJO")
    @PutMapping("/member_receive_address_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    //@RequiresPermissions("meimeimallmember:memberreceiveaddress:save")
    public R save(@RequestBody MemberReceiveAddressEntity memberReceiveAddress) {
        memberReceiveAddressService.save(memberReceiveAddress);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("向数据库更新POJO")
    @PostMapping("/member_receive_address_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    //@RequiresPermissions("meimeimallmember:memberreceiveaddress:update")
    public R update(@RequestBody MemberReceiveAddressEntity memberReceiveAddress) {
        memberReceiveAddressService.updateById(memberReceiveAddress);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("从数据库删除POJO")
    @DeleteMapping("/member_receive_address_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    //@RequiresPermissions("meimeimallmember:memberreceiveaddress:delete")
    public R delete(@RequestBody Long[] ids) {
        memberReceiveAddressService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
